#ifndef __PVMVOICESOURCEMOD_H__
#define __PVMVOICESOURCEMOD_H__

#include "lib/pvmvoicesource.h"
#include "lib/decoders/mod/pvmvoicemod.h"
#include "pvm/pvmapi.h"
#include "lib/pvmsystem.h"

#include "lib/memory/pvmmemory.h"

class PVMVoiceSourceMOD : public IPVMVoiceSource, public PVMAllocableObject
{
protected:
	PVMVoiceSourceMOD();
public:
	virtual ~PVMVoiceSourceMOD();

	virtual IPVMVoice* CreateVoice(pvm_int samplesPerSecond, pvm_int bitsPerSample, pvm_int chanelsNum);
	virtual void Destroy();
	virtual pvm_int GetLengthMS();

	virtual pvm_bool GetOption(const pvm_char* optionName, void* optionVal, pvm_uint32* optionSize);
	virtual pvm_bool SetOption(const pvm_char* optionName, void* optionVal, pvm_uint32 optionSize);

	pvm_int GetRefCount();
	pvm_int Release();
	pvm_int AddRef();
public:
	static PVMVoiceSourceMOD* Create(void *mod);
protected:
	pvm_int8* m_mh;
	pvm_uint32     m_freq, m_virtfreq;
	pvm_uint32 m_speed;
private:
	PVMCriticalSection critical;
	pvm_bool			criticalInitialized;
	pvm_int				refCount;
	pvm_uint32 defaultChanelsPan[PVMVoiceMOD::EPVM_MOD_MAXCHANNEL];

	friend class PVMVoiceMOD;
};

#endif
